# -*- coding: utf-8 -*-

class ReadWorkbook:
    from xlrd import open_workbook,cellname,XL_CELL_NUMBER
    book = open_workbook('cna131fresultados.xls')
    sheet = book.sheet_by_index(0)
    print book.encoding
    print sheet.name
    print sheet.nrows
    print sheet.ncols
        
    def encodeValue(v):
        try:
            return v.encode('utf-8', 'ignore')
        except AttributeError:
            return v

    for row_index in range(sheet.nrows):
    	for col_index in range(sheet.ncols):
            print cellname(row_index,col_index),'-',
            cellvalue = sheet.cell(row_index,col_index).value
            
            print encodeValue(cellvalue)
            

# class CreateDatabase:
#     import sqlite3

#     conn = sqlite3.connect('cna131fresultados-test.db')
#     c = conn.cursor()
#     # c.execute('''CREATE TABLE resultados
#              # (cod_instituicao real, cod_curso text, nome_instituicao text, grau text, vagas_iniciais real, colocados real, notas real, vagas_sobra real)''')
#     c.execute("INSERT INTO resultados VALUES ('','','','',100,35.14, 10, 20)")
#     conn.commit()

    
#     for row in c.execute('SELECT * FROM resultados ORDER BY cod_curso'):
#         print row
#     conn.close()